/*
 * BinaryAndOperatorAst.cpp
 *
 *  Created on: 1 Nov 2010
 *      Author: ph1109
 */

#include <MAlice/Ast/BinaryAndOperatorAst.h>

#include <MAlice/Parser/location.hh>
namespace MAlice
{

BinaryAndOperatorAst::BinaryAndOperatorAst(location loc, ExpressionAst* lhs,
		ExpressionAst* rhs) :
	BinaryOperatorAst(loc, "&", lhs, rhs)
{
	MALICE_TRACE;
}

BinaryAndOperatorAst::~BinaryAndOperatorAst()
{
	MALICE_TRACE;
}

llvm::Value* BinaryAndOperatorAst::generate()
{
	MALICE_TRACE;
	llvm::Value* LHS = getLHS()->generate();
	llvm::Value* RHS = getRHS()->generate();

	checkType(LHS, RHS);

	Builder* builder = MAlice::Codegen::get()->getBuilder();

	return builder->CreateAnd(LHS, RHS);
}

}
